package ltaa.sponsoredsearch.GAM;

import java.util.Map;
import java.util.HashMap;

class GeneralizedAuctionMechanism {
	public static final double MAX_VALUE = 1000000;
	public static final int SILENT = 0;
	public static final int VERBOSE = 1;
	public static final int CHATTY = 2;
	public static final int EXTREME = 3;

	public static int verbosity = 0;

	public static void main(String[] args) {
		
		int i = 0;
		String arg;
		String filename = "", option = "";

		while (i < args.length) {
			arg = args[i++];

			if (args[0].equals("--usage") || args[0].equals("--help")) {
				printUsage();
				System.exit(0);
			}

			if (arg.equals("-f")) {
				if (i < args.length) {
					filename = args[i++];
				} else {
					System.err.println("-f requires filename.");
				}
			} else if (arg.equals("-verbose")) {
				verbosity = VERBOSE;
			} else if (arg.equals("-chatty")) {
				verbosity = CHATTY;
			} else if (arg.equals("-extreme")) {
				verbosity = EXTREME;
			}
		}

		if (filename.equals("")) filename = "sampleDate"+java.io.File.separator+
				"default.txt";
		if (option.equals("")) option = "simple";

		BidsParser source = new BidsParser(filename);

		source.parse();
		Bidder[] bidders = source.getBidders();

		BipartiteGraph myBipGraph = new BipartiteGraph(bidders, source.getTotItems());

		Outcome o =  myBipGraph.solve();

		System.out.println("***********************");

		System.out.println(o.toString());
	}

	private static void printUsage() {
		System.out.println("Usage: java -cp bin "+
		"ltaa.sponsoredsearch.GAM.GeneralizedAuctionMechanism [-f datafile]"+
		"[VERBOSITY]");
		System.out.println("\tWhere VERBOSITY = {-verbose, -chatty, -extreme}");
	}

}
